package com.zyb.lmbackend.config;

import com.zyb.lmbackend.llm.BailianLlmClient;
import com.zyb.lmbackend.llm.DirectDashscopeLlmClient;
import com.zyb.lmbackend.llm.LlmClient;
import com.zyb.lmbackend.service.LlmCallAuditService;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * LLM 客户端装配：根据配置选择直连(direct)或应用(agent)模式。
 */
@Configuration
public class LlmClientConfig {

    @Value("${app.llm.provider:agent}")
    private String provider;

    @Bean
    public LlmClient llmClient(AiProperties aiProperties,
                               LlmCallAuditService auditService,
                               MeterRegistry meterRegistry) {
        if ("direct".equalsIgnoreCase(provider)) {
            return new DirectDashscopeLlmClient(aiProperties, auditService, meterRegistry);
        }
        // default to agent (apps/completion)
        return new BailianLlmClient(aiProperties, auditService, meterRegistry);
    }
}
